Skip to main content link. Accesskey S
  • Help
  • HCL Logo
  • HCL Notes and Domino Application Development wiki
  • THIS WIKI IS READ-ONLY. Individual names altered for privacy purposes.
  • HCL Forums and Blogs
  • Home
  • Product Documentation
  • Community Articles
  • Learning Center
  • API Documentation
Search
Community Articles > Designing Applications > Designing XPage Applications > Coloring Specific View Rows Using a Dynamic Table and CSS in XPages
  • Share Show Menu▼
  • Subscribe Show Menu▼

Recent articles by this author

New 8.5.1 Design Feature Cleans Up XPage Design When Using Custom Controls

If you have done any XPage development at all you know the power of using custom controls in your XPage design.  One issue though is if you are using many custom controls on an XPage it is difficult to tell where the XPage design elements start/end and the Custom Control elements start/end. ...

Creating a Dynamic HTML Table on an XPage

At first glance this seems like an exercise in can it be done versus should it be done.  So lets review our options for "dynamic" output of data on an XPage.  There are two controls you can use View Control Data Table Control  Both of these controls use a repeat control to display the contents of ...

Coloring Specific View Rows Using a Dynamic Table and CSS in XPages

I had a student ask recently about the ability to set the background color of a table row based upon a value in the data.  This is something that was pretty commonly done in traditional Domino Web Development.  In investigating how to do this I couldn't find a way to implement this using the ...

Using XML as an XPage Data Source

So the first question is why would we use an Domino XML Data Source instead of a standard view design? I'm glad you asked. A couple of reasons. Views can be limited to the amount of data that they display in the alloted columns. Using Java and LotusScript developers can write agents that returned ...

Complete Turnkey NSF to Transform DXL into XPage Syntax

In the turnkey Notes application I have made available on my  download site  (http://www.nnsu.com) I have created a Form that allows developers to choose an application from their local system or a server, select the Forms, Sub-Forms and Shared Fields to be transformed and simply click an action ...
Community articleColoring Specific View Rows Using a Dynamic Table and CSS in XPages
Added by ~Ben Breponejip | Edited by ~Fred Ektumilitetsi on April 25, 2016 | Version 3
  • Actions Show Menu▼
expanded Abstract
collapsed Abstract
No abstract provided.
Tags: XPages, CSS, Themes
I had a student ask recently about the ability to set the background color of a table row based upon a value in the data.  This is something that was pretty commonly done in traditional Domino Web Development.  In investigating how to do this I couldn't find a way to implement this using the standard View control, so I developed the following technique.

I use a dynamic html table (I showed how to implement this in my post hereexternal link ) but this technique can be used with a Data Table as well.

Create a CSS Style sheet that will map the colors to be used to the data values from the Domino View data. In the View I'm using as a data source there is a column that contains a Status value with one of the following values in it

  • New
  • Existing
  • Terminated
  • Pending

I have the following CSS in a stylesheet resource called rowclasses.css that I will be using in this demo.

.New {
background-color: red;
}
.Existing {
background-color: blue;
}
.Terminated {
background-color: fuchsia;
}

The class definitions in the CSS stylesheet are the same as the values from the status column.

Add the style sheet as a resource for the XPage.

 


 Before the Stylesheet is applied the XPage rendered in the browser looks like the following

 

We want the individual table rows background color to be set using the colors from the CSS style sheet based upon the value from the Status column in the View data.

To review, the dynamic table uses a repeat control that has a variable called "customers" for each row of data that will be displayed.  The value in the status column can be read from that variable using the Expression Language syntax customers.Status.

To set the value of the table rows background color, select the table row.  On the Style tab of the Properties tab click the computed diamond icon next to the Class field and choose "Compute value...".

 

In the Script Editor dialog box that opens up change the language to Expression Language and type in the expression customers.Status.  Click the OK button to save the expression to the class field.

Save the XPage and preview it in the browser.  Now each rows background color will be set to the value in the CSS stylesheet based upon the value from the status column.

The status column does not have to be displayed, but it does have to be available in the data.

The style does not have to be applied to the entire row, it could be applied to one or many table cells as well.

The application with complete source code can be downloaded from my website hereexternal link 


  • Actions Show Menu▼


expanded Attachments (0)
collapsed Attachments (0)
Edit the article to add or modify attachments.
expanded Versions (3)
collapsed Versions (3)
Version Comparison     
VersionDateChanged by              Summary of changes
This version (3)Apr 25, 2016, 10:07:17 AM~Fred Ektumilitetsi  
2Feb 23, 2010, 5:24:55 PM~Cheryl Elhipigenlen  
1Feb 23, 2010, 5:22:11 PM~Cheryl Elhipigenlen  
expanded Comments (0)
collapsed Comments (0)
Copy and paste this wiki markup to link to this article from another article in this wiki.
Go ElsewhereStay ConnectedAbout
  • HCL Software
  • HCL Digital Solutions community
  • HCL Software support
  • BlogsDigital Solutions blog
  • Community LinkHCL Software forums and blogs
  • About HCL
  • Privacy
  • Accessibility